﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utils
{

    /// <summary>
    /// 正则规则（统一配置正则规则）
    /// </summary>
    public class RegexRule
    {
        /// <summary>
        /// 用户名正则规则
        /// </summary>
        public const string UserName = @"^([\w\d_\u4e00-\u9fa5]){6,20}$";

        /// <summary>
        /// 用户昵称正则规则
        /// </summary>
        public const string NickName = @"^([\w\d_\u4e00-\u9fa5]){2,16}$";

        /// <summary>
        /// 权限名称规则
        /// </summary>
        public const string AuthorityLimit = @"^([\w\d_]|[\u4e00-\u9fa5]){2,20}$";

        /// <summary>
        /// 手机正则规则
        /// </summary>
        public const string Phone = @"^(1[3|4|5|7|8][0-9]{9}$)|(178[0-9]{8}$)"; // @"^(13[0-9]|15[0-35-9]|14[57]|18[02356789]){1}\d{8}$";

        /// <summary>
        /// 手机和电话的正则规则
        /// </summary>
        public const string PhoneAndTelePhone = @"(^(\d{3,4})?\d{7,8})$|(^(\d{3,4}-)?\d{7,8})$|(^(\d{3,4})?\d{7,8}(-\d{1,5}))$|(^(\d{3,4}-)?\d{7,8}(-\d{1,5}))$|^((\+86)|(86))?(1[3|5|8][0-9]{9})$";

//@"(^(\d{3,4}-)?\d{7,8})$|^((\+86)|(86))?(1[3|5|8][0-9]{9})$";
        //包含 电话号码(支持分机号)和手机号的正则表达式 

        //(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$;

        /// <summary>
        /// 邮件正则规则
        /// </summary>
        public const string Email = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

        /// <summary>
        /// 密码正则规则
        /// </summary>
        public const string PassWord = @"^[A-Za-z][A-Za-z0-9]{5,21}$";

        /// <summary>
        /// QQ正则规则
        /// </summary>
        public const string QQ = @"^\d{5,11}$";

        /// <summary>
        /// 纯数字正则规则
        /// </summary>
        public const string Number = @"^\d+$";


        /// <summary>
        /// 小数点后两位
        /// </summary>
        public const string Number2 = @"^(\d+)(.\d{1,2})?$";
        /// <summary>
        /// 小数点后一位
        /// </summary>
        public const string Number1 = @"^(\d+)(.\d{1,1})?$";

        /// <summary>
        /// 折扣百分比（0.01~99.99）
        /// </summary>
        public const string Discount = @"((^[1-9][0-9])(.\d{1,2})?$)|((^[0-9])(.\d{1,2})?$)";
        /// <summary>
        /// 折扣1-100
        /// </summary>
        public const string Discount2 = @"^100$|^[1-9]\d{0,1}$";
        /// <summary>
        /// 中文_英文字母_数字的混合  2到12位字符
        /// </summary>
        public const string CH_LetterOrNum = "^([\u4e00-\u9fa5]|[a-z_A-Z]|[0-9]){2,12}$";

        /// <summary>
        /// 职位名
        /// </summary>
        public const string RoleName = @"^([\w\d_]|[\u4e00-\u9fa5]){1,20}$";
        /// <summary>
        /// 日期
        /// </summary>
        public const string Date = @"^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$";
    }
}
